<!DOCTYPE html>
<!--[if IE 8]>			<html class="ie ie8"> <![endif]-->
<!--[if IE 9]>			<html class="ie ie9"> <![endif]-->
<!--[if gt IE 9]><!-->	<html> <!--<![endif]-->
<head>
	<meta charset="utf-8">
	<title>{:lang('forget password')} {$site_name} </title>
	<meta name="keywords" content="{$menu.menu_seo_key|default=$site_seo_keywords}" />
	<meta name="description" content="{$menu.menu_seo_des|default=$site_seo_description}">
	{include file="public:head" /}
</head>

<body class="body-white">
<div class="wrap">
	{include file="public:nav" /}
	<div id="main-cmf">
		<div class="content">
			<div class="container">
				<div class="row">
					<div class="col-lg-4 col-md-4 col-sm-6 col-xs-10 col-lg-offset-4 col-md-offset-4 col-sm-offset-3 col-xs-offset-1 animate_afr">
						<h2 class="text-center">{:lang('forget password')}</h2>
						<div class="widget tabs">
							<div id="horizontal-tabs">
								<div class="contents">
									<div class="tabscontent" id="content1" style="display: block;">
										<form class="form-light" id="forgot" action="{:url('home/Login/runforgot_pwd')}" method="post">
                                            <div id="forget_first">
                                            <div>
												<input type="mobile" name="mobile" id="mobile"  placeholder="* 注册的手机号码" class="form-control" required>
											</div>
											<div>&nbsp;</div>
                                            <div class="row">
												<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5"><input class="form-control" required name="mobilecode" id="mobilecode" type="text" placeholder="* 短信验证码"></div>
                                                <div class="col-lg-1 col-md-1 col-sm-1 col-xs-1"><button class="btn btn-primary " type="button" id="getcode">获取验证码</button></div>
											</div>
                                            </div> 
                                            
                                            
                                            
                                            <div id="forget_second" style=" display:none">
                                            
											<div>
												<input type="password" name="password" id="password"  placeholder="* 新密码" class="form-control" required>
											</div>
											<div>&nbsp;</div>
                                            <div>
												<input type="password" name="curr_password" id="curr_password"  placeholder="* 确认新密码" class="form-control" required>
											</div>
											<div>&nbsp;</div>
                                            <div class="row">
												<div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
													<input type="text" class="form-control" id="verify" placeholder="" style="height:40px;" name="verify" required>
												</div>
												<div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">
													<img class="verify_img" id="verify_img" src="{:url('home/Login/verify')}" onClick="this.src='{:url('home/Login/verify')}'+'?'+Math.random()" style="cursor: pointer;width:100%;border: 1px solid #d5d5d5;height:40px;" title="{:lang('click to get')}">
												</div>
											</div>
                                            
                                            </div>
                                        
                                         
											<div>&nbsp;</div>
											<div>
                                                <input type="hidden" id="step" value="1" name="step">
												<button class="btn btn-success col-lg-12 col-md-12 col-sm-12 col-xs-12" type="button" id="step_button">下一步</button>

											</div>
											<div>&nbsp;</div>
											<div style="text-align: center;">
												<div class="row">
													<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
														<a href="{:url('home/Register/index')}">{:lang('register immediately')}</a>
													</div>
													<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
														<a href="{:url('home/Login/index')}">{:lang('login')}</a>
													</div>
												</div>
											</div>
                                            <div>&nbsp;</div>
										</form>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	{include file="public:footer"/}
</div>
{include file="public:scripts"/}
<script>
var lock = false;
$(function(){

	$("#getcode").click(function(){	
	    if(lock){
		  layer.alert('正在发送中，请稍候...');
		}else{
	    var o = this,op  = $(this);
		var mobile = $("#mobile").val();						 
		if( mobile==""){
			layer.alert("请输入手机号码！");
			return false;
		}
		if(!checkStr(mobile,"mobile")){
			layer.alert("请输入正确的手机号码！");
			return false;
		}
		
		$.post('{:url("index/mobilecode")}',{mobile:mobile,mode:'forget'},function(res){
			if(res.err == 1){
			   lock = false;	
			   layer.alert(res.msg);
			}else{
			   lock = true;
			   $("#step").val('2');	
			   daojishi(this);	
			   checkdaojishi(document.getElementById("getcode"));	
			}
		},'json');
		
		}
		
	});
	
	
	$("#step_button").click(function(){
	   var code   = $("#mobilecode").val();
	   var mobile = $("#mobile").val();
	   var step   = $("#step").val();
	   if(step == '3'){
	      if($("#password").val()!=='' && $("#password").val() == $("#curr_password").val()){
		     $.post("{:url('home/login/forgotsubmit')}",$("#forgot").serialize(),function(res){
		         if(res.code == 1){
			        layer.msg(res.msg, {icon: 6,time:2000}, function(index){
						layer.close(index);
						window.location.href = "{:url('home/Login/index')}";
				    });
				 }else{
				   layer.msg(res.msg, {icon: 5,time:2000}, function(index){
						layer.close(index);
						if(res.code == -1)
						  changverify(); 
				   });
				 } 
			 },'json');
			 return true;
		  }else{
		     layer.alert('密码与确认密码不正确！');
		  }
	   }else{
	   if($("#step").val()!='2' || code ==''){
	     layer.alert('请发送并填写短信验证码！');
	   }else{
		 $.post('{:url("home/index/check_forget")}',{mobile:mobile,code:code},function(res){
		   if(res.err==1){
		      layer.alert(res.msg);
		   }else{
		      $("#forget_first").hide();
			  changverify();
			  $("#step").val('3');
			  $("#step_button").html('提交');
			  $("#forget_second").show(); 
		   }
		 },'json');
	   } 
	   }
	});
	
	 
	
});
function changverify(){
   var _url = '{:url("home/Login/verify")}'+'?'+Math.random();
   $("#verify_img").attr("src",_url);
}
</script>
</body>
</html>